package project.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import project.dao.UserDao;
import project.entity.User;
import project.utils.DruidUtil;

import java.sql.SQLException;

/*
杨威
2021/9/11
17:27
*/
public class UserDaoImpl implements UserDao {
    QueryRunner queryRunner=new QueryRunner();
    @Override
    public User select(String userName) {
        try {
            String sql="select * from user where userName=?";
            User query = queryRunner.query(DruidUtil.getConnection(), sql, new BeanHandler<>(User.class), userName);
            return query;
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage()+"查询用户出现异常");
        }
    }
}
